import { S } from '../../s';
import { IPSAppCounter } from './ipsapp-counter';
import { IPSAppDEAction } from '../dataentity/ipsapp-deaction';
import { IPSAppDEDataSet } from '../dataentity/ipsapp-dedata-set';
import { IPSAppDataEntity } from '../dataentity/ipsapp-data-entity';
import { IPSSysPFPlugin } from '../../res/ipssys-pfplugin';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSAppCounterImpl
  extends PSModelObjectImpl
  implements IPSAppCounter
{
  get codeName(): string {
    return this.M.codeName;
  }

  get counterData(): string {
    return this.M.counterData;
  }

  get counterData2(): string {
    return this.M.counterData2;
  }

  get counterType(): string {
    return this.M.counterType;
  }

  get customCond(): string {
    return this.M.customCond;
  }

  protected getpsappdeaction: IPSAppDEAction;
  getGetPSAppDEAction(): IPSAppDEAction | null {
    if (this.getpsappdeaction != null) return this.getpsappdeaction;
    const value = this.M.getGetPSAppDEAction;
    if (value == null) {
      return;
    }
    const ipsappdataentity = this.getPSAppDataEntity();
    if (ipsappdataentity != null) {
      this.getpsappdeaction = ipsappdataentity.findPSAppDEAction(value);
    }
    return this.getpsappdeaction;
  }

  protected getpsappdedataset: IPSAppDEDataSet;
  getGetPSAppDEDataSet(): IPSAppDEDataSet | null {
    if (this.getpsappdedataset != null) return this.getpsappdedataset;
    const value = this.M.getGetPSAppDEDataSet;
    if (value == null) {
      return;
    }
    const ipsappdataentity = this.getPSAppDataEntity();
    if (ipsappdataentity != null) {
      this.getpsappdedataset = ipsappdataentity.findPSAppDEDataSet(value);
    }
    return this.getpsappdedataset;
  }

  protected psappdataentity: IPSAppDataEntity;
  getPSAppDataEntity(): IPSAppDataEntity | null {
    return (
      this.psappdataentity ||
      (this.psappdataentity = this.fillObjectModel(
        S._f,
        this.M.getPSAppDataEntity,
        S._2aa,
      ) as IPSAppDataEntity)
    );
  }

  getPSCounterId(): string {
    return this.M.getPSCounterId;
  }

  protected pssyspfplugin: IPSSysPFPlugin;
  getPSSysPFPlugin(): IPSSysPFPlugin | null {
    return (
      this.pssyspfplugin ||
      (this.pssyspfplugin = this.fillObjectModel(
        S._27c,
        this.M.getPSSysPFPlugin,
        S._2a7,
      ) as IPSSysPFPlugin)
    );
  }

  get timer(): number {
    return this.M.timer != null ? this.M.timer : 0;
  }
  get cls(): string {
    return 'PSAppCounterImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._a || cls == S._b) return true;
    return super.instanceof(cls);
  }
}
